<?php

namespace app\middleware;

use app\BaseController;

class IsLogin extends BaseController
{
    public function handle($request, \Closure $next)
    {
        $token = $this->getToken();
        if(empty($token)){
            return $this->show(
                config('status.goto'),
                config('status.message'),
                "非法请求"
            );
        }
        $user = $this->getUser();
        if(empty($user)){
            return $this->show(
                config('status.goto'),
                config('status.message'),
                "登陆过期"
            );
        }


        // 继续处理其他请求
        return $next($request);
    }
}
